package com.hpdf.dao.impl;

import java.util.List;

import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.github.pagehelper.PageHelper;
import com.hpdf.dao.DomeDao;
import com.hpdf.domain.TbDCarinfo;
import com.hpdf.domain.param.TbDCarinfoRequest;
import com.hpdf.mapper.TbDCarinfoMapper;
import com.hpdf.mapper.smapper.TbDCarinfoSmapper;
import com.hpdf.utils.PageBeanUtil;
import com.hpdf.utils.web.resultbean.PageBean;
@Component
public class DomeDaoImpl implements DomeDao {

	@Autowired
	private  TbDCarinfoSmapper tbDCarinfoSmapper;
	
	@Autowired
	private  TbDCarinfoMapper tbDCarinfoMapper;
	
	
	
	@Override
	public TbDCarinfo queryCarinfo(TbDCarinfo carinfo) {
		//return tbDCarinfoMapper.selectByPrimaryKey(carinfo.getCarid());
		return tbDCarinfoSmapper.queryCarinfo(carinfo);
	}
	@Override
	public PageBean<TbDCarinfo> queryCarinfoForList(TbDCarinfoRequest tbDCarinfoRequest) {
		TbDCarinfo tbDCarinfo = new TbDCarinfo();
		// 1.设置分页信息
	    PageHelper.startPage(tbDCarinfoRequest.getPageNum(), tbDCarinfoRequest.getPageSize());
	    if(tbDCarinfoRequest != null ){
			BeanUtils.copyProperties(tbDCarinfoRequest, tbDCarinfo);
		}
	    //2.查询数据
	    List<TbDCarinfo>  list = tbDCarinfoSmapper.queryCarinfoForList(tbDCarinfo);
		return PageBeanUtil.setPageResult(list);
	}
	@Override
	public int insertInCarinfo(TbDCarinfo carinfo) {
		
		return tbDCarinfoMapper.insert(carinfo);
	}

}
